package com.way.capture.base;

import android.os.Bundle;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;

import com.way.capture.utils.Settings;
import com.way.capture.utils.Utils;

import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.disposables.CompositeDisposable;

/**
 * Created by android on 16-3-5.
 */
public abstract class BaseActivity extends AppCompatActivity {
    @NonNull
    protected final CompositeDisposable mSubscriptions = new CompositeDisposable();
    private Unbinder mUnbinder;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final boolean isNightMode = Settings.getInstance().isNightMode();
        AppCompatDelegate.setDefaultNightMode(isNightMode ? AppCompatDelegate.MODE_NIGHT_YES
                : AppCompatDelegate.MODE_NIGHT_NO);
        Utils.setStatusBarStyle(this, isNightMode);

        setContentView(getContentView());
        Utils.getNotchParams(this);

        mUnbinder = ButterKnife.bind(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mSubscriptions.clear();
        if (mUnbinder != null) {
            mUnbinder.unbind();
        }
    }

    protected abstract @LayoutRes
    int getContentView();

}
